<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>mixin内部继承与super关键字</title>
</head>
<body>
    <script>
        function User(name,age){
            this.name = name;
            this.age = age;
        }

        User.prototype.show = function(){
            console.log(this.name,this.age)
        }

        // 将其他方法放到对象在
        const address = {
            getAddress(){
                return '地址';
            }
        };

        // creit继承address
        const creit = {
            __proto__ : address,
            total(){
                // super相当于this.__proto__
                console.log(super.getAddress() + "   积分统计");    //console.log((this.__proto__).getAddress() + "   积分统计");
            }
        };


        function extend(sub,sup){
            sub.prototype = Object.create(sup.prototype);
            Object.defineProperty(sub.prototype,'constructor',{
                value:sub,
                enumerable:false
            });  
        }


        function Admin(name,age){
            User.call(this,name,age);
        }
        extend(Admin,User); 
        // 将 要使用的对象合并到Admin.prototype中
        Admin.prototype = Object.assign(Admin.prototype,creit);
        let admin = new Admin('xiasnn',18);
        admin.show();
        admin.total();
    </script>
</body>
</html>